package cn.wolfcode.crm.service.imp;

import cn.wolfcode.crm.domain.SpendPoint;
import cn.wolfcode.crm.mapper.SpendPointMapper;
import cn.wolfcode.crm.service.ISpendPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class SpendPointServiceImpl implements ISpendPointService {
    @Autowired
    private SpendPointMapper spendPointMapper;


    public List<SpendPoint> selectAll() {
        return spendPointMapper.selectAll();
    }

    public Boolean selectByName(Long id, String name) {
        SpendPoint spendPoint = spendPointMapper.selectByName(name);
        return spendPoint==null||spendPoint.getId()==id;
    }

    public void saveOrUpdate(SpendPoint spendPoint) {
        /*维护关系*/
        if (spendPoint.getId() == null) {
            spendPointMapper.insert(spendPoint);
        }else{
            spendPointMapper.updateByPrimaryKey(spendPoint);
        }
    }

    public void delete(Long id) {
        if(id!=null){
            spendPointMapper.deleteByPrimaryKey(id);
        }
    }
}
